<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      const user = {
        username: 'jack',
        age: 20,
        gender: 'boy',
      };
      console.log(String(user)); //[object Object]
      //JSON格式的字符串： 双引号，属性加引号，去掉最后一个逗号
      console.log(JSON.stringify(user)); //{"username":"jack","age":20,"gender":"boy"}
      console.log(JSON.stringify([1, 2, 3, 'hello'])); // [1,2,3,"hello"]

      console.log(JSON.stringify('hello')); // "hello"
      console.log(JSON.stringify(true)); // true
      console.log(JSON.stringify(null)); //null
      console.log(JSON.stringify(123)); //123
      // console.log(JSON.stringify(Symbol('hello'))); //
      // console.log(JSON.stringify(undefined)); //
      // console.log(JSON.stringify(function () {})); //
    </script>
  </body>
</html>
